<?php

namespace app\http\api\controller;

use app\http\api\service\ProductService;
use DI\Attribute\Inject;
use support\Request;
use support\Response;

class Product
{
    #[Inject]
    protected ProductService $productService;

    public function index(Request $request): Response
    {
        $data = [
            'keyword'     => $request->post('keyword', ''),
            'start'       => $request->post('start', 0),
            'length'      => $request->post('length', 10),
            'is_shop'     => $request->post('is_shop', 1), //是否为商城：0 否，1是
            'status'      => $request->post('status', 1), //商品状态： 空全部， 0 下架，1 上架
            'weight_type' => $request->post('weight_type'), //计价类型：0 全部，1 计价，2 计重
        ];
        return json($this->productService->getList($data));
    }
}